package com.likan.chqjtgc.commons;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @author liuxinghong
 * @date 2019/5/3
 */

@ApiModel("分页")
public class PageVo<T> implements Serializable {

    @ApiModelProperty("当前页")
    private Integer current =1;
    @ApiModelProperty("每页的条数")
    private Integer size=15;
    /**
     * 排序字段
     */
    @ApiModelProperty("排序字段")
    private String sortField;
    /**
     * 排序方向(0 desc倒序,1 asc正序)
     */
    @ApiModelProperty("排序方向")
    private Integer direction = 0;//默认倒序

    @Valid
    @NotNull(message = "params参数不能为空！")
    private T params;

    /**
     * 扩展字段
     */
    private Object ex;

    public PageVo() {
    }

    public PageVo(Integer current, Integer size, @Valid @NotNull(message = "params参数不能为空！") T params) {
        this.current = current;
        this.size = size;
        this.params = params;
    }

    public PageVo(Integer current, Integer size, String sortField, @Valid @NotNull(message = "params参数不能为空！") T params) {
        this.current = current;
        this.size = size;
        this.sortField = sortField;
        this.params = params;
    }

    public PageVo(Integer current, Integer size, String sortField, Integer direction, @Valid @NotNull(message = "params参数不能为空！") T params) {
        this.current = current;
        this.size = size;
        this.sortField = sortField;
        this.direction = direction;
        this.params = params;
    }

    public Integer getCurrent() {
        return current;
    }

    public void setCurrent(Integer current) {
        this.current = current;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public Integer getDirection() {
        return direction;
    }

    public void setDirection(Integer direction) {
        this.direction = direction;
    }

    public T getParams() {
        return params;
    }

    public void setParams(T params) {
        this.params = params;
    }

    public Object getEx() {
        return ex;
    }

    public void setEx(Object ex) {
        this.ex = ex;
    }
}
